package com.zhongke.cotrun.service.impl;

import com.zhongke.cotrun.mapper.CompanyInfoMapper;
import com.zhongke.cotrun.model.pojo.CompanyInfo;
import com.zhongke.cotrun.service.CompanyInfoService;
import com.zhongke.cotrun.shiro.sys.shiro.ShiroUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("companyInfoService")
public class CompanyInfoServiceImpl implements CompanyInfoService {

    @Resource
    CompanyInfoMapper companyInfoMapper;

    @Override
    public List<CompanyInfo> selectAll() {
        return companyInfoMapper.selectAll();
    }

    @Override
    public boolean saveCompanyInfo(CompanyInfo companyInfo) {
        companyInfo.setLinkUserId(ShiroUtils.getUserId1());
        return companyInfoMapper.saveCompanyInfo(companyInfo);
    }

    @Override
    public boolean updateCompanyInfo(CompanyInfo companyInfo) {
        companyInfo.setLinkUserId(ShiroUtils.getUserId1());
        companyInfo.setAuditStatus(0);
        return companyInfoMapper.updateCompanyInfo(companyInfo);
    }

    @Override
    public boolean approvalPass(Long companyId) {
        String userName = ShiroUtils.getUserName();
        return companyInfoMapper.approvalPass(companyId,userName);
    }

    @Override
    public boolean approvalRejected(Long companyId, String auditOpinion) {
        String userName = ShiroUtils.getUserName();
        return companyInfoMapper.approvalRejected(companyId,userName,auditOpinion);
    }
}
